<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>可撤销代理</title>
</head>
<body>
  <script>
    const target = {
      foo: 'bar'
    };

    const { proxy, revoke } = Proxy.revocable(target, {
      get() {
        return 'intercepted';
      }
    });

    console.log(proxy.foo);  // intercepted
    console.log(target.foo);  // bar

    revoke();

    console.log(proxy.foo);  // TypeError
  </script>
</body>
</html>